package com.swiftride.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swiftride.mapper.CustomerCarMapper;
import com.swiftride.pojo.domain.CustomerCar;
import com.swiftride.pojo.dto.CarInfoDto;
import com.swiftride.service.ICustomerCarService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 客户车辆 服务实现类
 * </p>
 *
 * @author wy
 * @since 2024-07-31
 */
@Service
public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, CustomerCar> implements ICustomerCarService {

    @Override
    public List<CustomerCar> getList() {
        return list(new LambdaQueryWrapper<CustomerCar>().
                eq(CustomerCar::getCustomerId, StpUtil.getLoginIdAsLong()));
    }

    @Override
    public void saveCatInfo(CarInfoDto carInfoDto) {
        CustomerCar customerCar = new CustomerCar();
        customerCar.init();
        customerCar.setCustomerId(StpUtil.getLoginIdAsLong());
        customerCar.setCarPlate(carInfoDto.getCarPlate());
        customerCar.setCarType(carInfoDto.getCarType());
        save(customerCar);
    }
}
